
let UIConstant = require('../ui2/ui_constants');

class State {

    constructor() {
        this._id = window.myTools.genId();
        // 记录鼠标到锚点的位置
        this._offx = 0;
        this._offy = 0
    }

    get id() {
        return this._id;
    }

    onEnter() {
        // 记录鼠标到锚点的位置
        this._offx = 0;
        this._offy = 0
    }

    onExit() {
        // 不选中东西
        editor.gameApp.selectDeco(null);
    }

    touchBegin(event){}
    touchMove(event){}
    touchEnd(event){}
    touchCancel(event){}


    //------------------------------
    // apis
    hideDeco() {
        // 1. 除了 两个 battery deco 全部隐藏
        let lstDeco = editor.getDecoView().getModel();
        for (let i = 2, len = lstDeco.length; i < len; ++i) {
            if (!lstDeco[i].hole) {
                lstDeco[i].node.active = false;
            }
        }
    }

    hideBattery() {
        let lstDeco = editor.getDecoView().getModel();
        for (let i = 0; i < 2; ++i) {
            lstDeco[i].node.active = false;
        }
    }

    showBattery() {
        // 判断当前是个什么状态
        let mapView = editor.getMapView();
        let cannoType = mapView.getModel().cannoType;
        let mapScene = editor.gameApp;
        mapScene.getDefaultBattery().node.active = true;
        if (cannoType == UIConstant.CannoType.Double) {
            mapScene.showDoubleBattery();
        } else {
            mapScene.showSingleBattery();
        }
    }

    showDeco() {
        let lstDeco = editor.getDecoView().getModel();
        for (let i = 2, len = lstDeco.length; i < len; ++i) {
            lstDeco[i].node.active = true;
        }
    }
}

module.exports = State;